package com.devilvan.betrice.mg.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.mg.dto.MgPreviewPicDto;
import com.devilvan.betrice.mg.po.MgPreviewPicPo;
import com.devilvan.betrice.mg.service.MgPreviewPicService;
import com.devilvan.betrice.mg.mapper.MgPreviewPicMapper;
import com.devilvan.betrice.mg.repository.MgPreviewPicRepository;
import com.devilvan.betrice.util.UCopy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description 198763-预览图片表 业务逻辑类
* @date 2023-01-26
*/
@Service
public class MgPreviewPicServiceImpl extends ServiceImpl<MgPreviewPicMapper, MgPreviewPicPo> implements MgPreviewPicService {
    @Resource(name = "mgPreviewPicRepository")
    private MgPreviewPicRepository mgPreviewPicRepository;

    @Override
    public MgPreviewPicPo saveUpdate(MgPreviewPicDto mgPreviewPicDto) {
        MgPreviewPicPo mgPreviewPicPo = new MgPreviewPicPo();
        UCopy.fullCopy(mgPreviewPicDto, mgPreviewPicPo);
        return mgPreviewPicRepository.saveAndFlush(mgPreviewPicPo);
    }

    @Override
    public List<MgPreviewPicPo> saveUpdateBatch(List<MgPreviewPicDto> list) {
        List<MgPreviewPicPo> mgPreviewPicPoList = UCopy.fullCopyCollections(list, MgPreviewPicPo.class);
        return mgPreviewPicRepository.saveAllAndFlush(mgPreviewPicPoList);
    }
}
